﻿using Runtime.Services.Battle;
using UnityEngine;

public static class DFR_BattleUtilitiesTD {

    public static DFR_BattleDirection GetDirection(DFR_BattleCellAxis start, DFR_BattleCellAxis end) {
        if (end.X < start.X) {
            return DFR_BattleDirection.Left;
        } else if (end.X > start.X) {
            return DFR_BattleDirection.Right;
        } else if (end.Y > start.Y) {
            return DFR_BattleDirection.Up;
        } else if (end.Y < start.Y) {
            return DFR_BattleDirection.Down;
        } else {
            return DFR_BattleDirection.None;
        }
    }

    public static Vector3 Forward(Vector3 start, DFR_BattleDirection direction, float distance) {
        switch (direction) {
            case DFR_BattleDirection.Left:
                distance *= BattleServiceTD.Instance.CellWidth;
                start -= new Vector3(distance, 0f);
                break;
            case DFR_BattleDirection.Right:
                distance *= BattleServiceTD.Instance.CellWidth;
                start += new Vector3(distance, 0f);
                break;
            case DFR_BattleDirection.Up:
                distance *= BattleServiceTD.Instance.CellHeight;
                start += new Vector3(0f, distance);
                break;
            case DFR_BattleDirection.Down:
                distance *= BattleServiceTD.Instance.CellHeight;
                start -= new Vector3(0f, distance);
                break;
        }
        return start;
    }
}
